﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QLFUI
{
    public partial class FormHideenResize : Form
    {
        private FormBase parentForm;

        public FormHideenResize(FormBase fb)
        {
            parentForm = fb;
            InitializeComponent();

            SetStyle(
              ControlStyles.OptimizedDoubleBuffer |
              ControlStyles.UserPaint |
              ControlStyles.ResizeRedraw |
              ControlStyles.SupportsTransparentBackColor |
              ControlStyles.AllPaintingInWmPaint, true);
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
             base.OnPaintBackground(e);

            //e.Graphics.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(Location, Size));
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Size = new Size(parentForm.Size.Width + 2, parentForm.Size.Height + 2);
            Left = parentForm.Location.X - 1;
            Top = parentForm.Location.Y - 1;

            //Left = Top = 0;
            //Width = Screen.PrimaryScreen.WorkingArea.Width + 2;
            //Height = Screen.PrimaryScreen.WorkingArea.Height + 2;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (parentForm != null)
            {
                Graphics g = e.Graphics;
                g.DrawRectangle(new Pen(Color.Red, 2), new Rectangle(0,0,Size.Width,Size.Height));
                //g.DrawRectangle(new Pen(Color.Red, 2), new Rectangle(parentForm.Left, parentForm.Top,
                //    parentForm.Width, parentForm.Height));

            }
        }
    }
}
